package environment;

import jade.core.Agent;
import gui.CasillaEvent;
import gui.CasillasGUI;

public class Casilla {
	
	public static final int CARGADOR=1;
	public static final int ENTREGAAZUL=2;
	public static final int ENTREGAROJO=3;
	public static final int ENTREGAVERDE=4;
	public static final int ENTREGAAMARILLO=5;
	public static final int PAQUETEAZUL=6;
	public static final int PAQUETEROJO=7;
	public static final int PAQUETEVERDE=8;
	public static final int PAQUETEAMARILLO=9;
	public static final int AGENTE=10;
	public static final int AGENTECARGADOR=11;

	
	private Tablero tablero;
	private int contenido;
	private boolean loader;
	private int gradiente;
	private CasillasGUI guiElement;
	private int agentLoad;

	/***/

	public Casilla(Tablero t) {
		this.tablero = t;
		this.contenido = 0;
		this.gradiente = 0;
		this.loader = false;
		this.guiElement = null;
		this.agentLoad = 0;
	}

	/***/

	public Tablero getTablero() {
		return tablero;
	}
	
	/***/

	public int getContenido() {
		return contenido;
	}
	
	/***/

	public boolean hasLoader() {
		return loader;
	}
	
	/***/

	public void setContenido(int contenido) {
		this.contenido = contenido;
		if (contenido == 1) {
			this.loader = true;
		}
	}
	
	/***/
	
	public void updateGui() {
		if (guiElement != null) {
			CasillaEvent e = new CasillaEvent(this, this.contenido + this.agentLoad);
			guiElement.casillaUpdate(e);
		}
	}
	
	/***/

	public int getGradiente() {
		return gradiente;
	}
	
	/***/

	public void setGradiente(int gradiente) {
		this.gradiente = gradiente;
	}
	
	/***/

	public String coordsStr() {
		int[] cd  = tablero.getCoordenadas(this);
		String s = "c("+cd[0]+","+cd[1]+")";
		return s;
	}
	
	/***/
	
	public CasillasGUI getGuiElement() {
		return guiElement;
	}
	
	/***/

	public void setGuiElement(CasillasGUI guiElement) {
		this.guiElement = guiElement;
	}
	
	/***/

	public int getAgentLoad() {
		return agentLoad;
	}

	public void setAgentLoad(int agentLoad) {
		this.agentLoad = agentLoad;
	}

}
